// 导入http模块
const http = require("http");
// 创建服务
const server =http.createServer();

// 调用on
server.on("request",(req,res)=>{

    const url = req.url;
    let content = "<h1> 404 Not found! </h1>"
    if(url==='/' || url === "/index.html"){
        content = "<h1>首页</h1>"
    }else if(url==="/about.html"){
        content = "<h1>关于</h1>"
    }

    // 设置请求头
    res.setHeader('Content-type','text/html; charset=utf-8');

    // res.setHeader("Content-Tyoe","text/html;charset=utf-8");

    res.end(content)

})

// 启用80端口
server.listen(80,()=>{
    console.log("http://127.0.0.1");
})